# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Josip Ponjavic <josipponjavic at gmail dot com>
# Contributor: Xu Fasheng <fasheng.xu[AT]gmail.com>

pkgname=deepin-wm
pkgver=1.9.38
pkgrel=7
pkgdesc='Deepin Window Manager'
arch=('loong64' 'x86_64')
url="https://github.com/linuxdeepin/deepin-wm"
license=('GPL3')
groups=('deepin')
depends=('bamf' 'clutter-gtk' 'deepin-desktop-schemas' 'deepin-menu' 'granite' 'deepin-mutter'
         'gnome-desktop' 'libgee')
makedepends=('gnome-common' 'intltool' 'vala')
options=('debug')
source=("$pkgname-$pkgver.tar.gz::https://github.com/linuxdeepin/deepin-wm/archive/$pkgver.tar.gz"
        vala.patch::https://github.com/linuxdeepin/deepin-wm/pull/65.patch)
sha512sums=('3eb4e47856611e0dc257ab079eff3166ed643aa8b55686519c917c3184cd5f238d01c3c8960d715a81264ff1337aa5d7c809a6559eab82e9decb1b9b8a33917d'
            'aac9bc11840f38981f37778c7a2d8ead78ed94673f3d84ba167d68281ae2c03845ace98146ae2db269472c5c722be5eb577b7f5f7e97afd6d1f373af2deb35b8')

prepare() {
  cd $pkgname-$pkgver
  patch -Np1 -i ../vala.patch

  # Newer vala again
  sed -e 's/background.set_rounds/background.value.set_rounds/' \
      -e 's/background.set_blurred/background.value.set_blurred/' \
      -e 's/background.set_radius/background.value.set_radius/' \
      -e 's/bg.set_transient_background/bg.value.set_transient_background/' \
      -i src/WindowManager.vala

  sed -i 's#/usr/share/backgrounds/default_background.jpg#/usr/share/backgrounds/deepin/desktop.jpg#' src/Background/BackgroundSource.vala
}

build() {
  export CFLAGS="$CFLAGS -DWNCK_I_KNOW_THIS_IS_UNSTABLE"

  cd $pkgname-$pkgver
  ./autogen.sh \
    --prefix='/usr' \
    --disable-schemas-compile
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
}
